.TH "frovedis::linear_regression_model<T>" "" "" "" ""
.SH NAME
.PP
\f[C]linear_regression_model<T>\f[] \- A data structure used in modeling
the outputs of the frovedis linear regression algorithms.
.SH SYNOPSIS
.PP
\f[C]#include\ <frovedis/ml/glm/linear_model.hpp>\f[]
.SS Constructors
.PP
linear_regression_model ()
.PD 0
.P
.PD
linear_regression_model (size_t num_ftr, T intercpt=0.0)
.PD 0
.P
.PD
linear_regression_model (const \f[C]linear_regression_model<T>\f[]&
model)
.PD 0
.P
.PD
linear_regression_model (\f[C]linear_regression_model<T>\f[]&& model)
.SS Overloaded Operators
.PP
\f[C]linear_regression_model<T>\f[]& operator= (const
\f[C]linear_regression_model<T>\f[]& model)
.PD 0
.P
.PD
\f[C]linear_regression_model<T>\f[]& operator=
(\f[C]linear_regression_model<T>\f[]&& model)
.PD 0
.P
.PD
\f[C]linear_regression_model<T>\f[] operator+ (const
\f[C]linear_regression_model<T>\f[]& model) const
.PD 0
.P
.PD
\f[C]linear_regression_model<T>\f[] operator\- (const
\f[C]linear_regression_model<T>\f[]& model) const
.PD 0
.P
.PD
void operator+= (const \f[C]linear_regression_model<T>\f[]& model)
.PD 0
.P
.PD
void operator\-= (const \f[C]linear_regression_model<T>\f[]& model)
.SS Public Member Functions
.PP
\f[C]std::vector<T>\f[] predict (DATA_MATRIX& mat)
.PD 0
.P
.PD
size_t get_num_features () const
.PD 0
.P
.PD
void save (const std::string& path) const
.PD 0
.P
.PD
void savebinary (const std::string& path) const
.PD 0
.P
.PD
void load (const std::string& path) const
.PD 0
.P
.PD
void loadbinary (const std::string& path) const
.PD 0
.P
.PD
void debug_print() const
.PD 0
.P
.PD
\f[C]node_local<linear_regression_model<T>>\f[] broadcast ()
.SH DESCRIPTION
.PP
\f[C]linear_regression_model<T>\f[] models the output of the frovedis
linear regression algorithms, e.g., linear regression, lasso regression
and ridge regression.
Each of the trainer interfaces of these algorithms aim to optimize an
initial model and output the same after optimization.
This model has the below structure:
.IP
.nf
\f[C]
template\ <class\ T>\ 
struct\ linear_regression_model\ {
\ \ std::vector<T>\ weight;\ //\ the\ weight\ vector\ associated\ with\ each\ input\ training\ features
\ \ T\ intercept;\ \ \ \ \ \ \ \ \ \ \ //\ the\ bias\ intercept\ term
\ \ SERIALIZE\ (weight,\ intercept)
};
\f[]
.fi
.PP
This is a template based data structure, where "T" is supposed to be
"float" (single\-precision) or "double" (double\-precision).
Note this is a serialized data structure.
The detailed description can be found in subsequent sections.
.SS Constructor Documentation
.SS linear_regression_model ()
.PP
Default constructor.
It creates an empty linear regression model with default "intercept"
value as 0.0.
.SS linear_regression_model (size_t num_ftr, T intercept=0.0)
.PP
Parameterized constructor.
It accepts the number\-of\-features input from the user and allocates
the memory for the model of the same size.
If no initial value of the "intercept" is provided, it considers the
default value as 0.0.
.SS linear_regression_model (const \f[C]linear_regression_model<T>\f[]&
model)
.PP
Copy constructor.
It accepts an lvalue object of the same type and deep\-copies the same
in the newly constructed object.
.SS linear_regression_model (\f[C]linear_regression_model<T>\f[]&&
model)
.PP
Move constructor.
It accepts an rvalue object of the same type and instead of copying, it
moves the contents in the newly constructed object.
.SS Overloaded Operator Documentation
.SS \f[C]linear_regression_model<T>\f[]& operator= (const
\f[C]linear_regression_model<T>\f[]& model)
.PP
It deep\-copies the contents of the input lvalue model into the
left\-hand side model of the assignment operator "=".
.SS \f[C]linear_regression_model<T>\f[]& operator=
(\f[C]linear_regression_model<T>\f[]&& model)
.PP
Instead of copying, it moves the contents of the input rvalue model into
the left\-hand side model of the assignment operator "=".
.SS \f[C]linear_regression_model<T>\f[] operator+ (const
\f[C]linear_regression_model<T>\f[]& model) const
.PP
This operator is used to add two linear regression models and outputs
the resultant model.
If m1 and m2 are two models, expression like "m1 + m2" can easily be
evaluated on them.
.SS \f[C]linear_regression_model<T>\f[] operator\- (const
\f[C]linear_regression_model<T>\f[]& model) const
.PP
This operator is used to subtract two linear regression models and
outputs the resultant model.
If m1 and m2 are two models, expression like "m1 \- m2" can easily be
evaluated on them.
.SS void operator+= (const \f[C]linear_regression_model<T>\f[]& model)
.PP
This operator is used to add two linear regression models.
But instead of returning a new model, it updates the target model with
the resultant model.
If m1 and m2 are two models, then "m1 += m2" will add m2 with m1 and
update m1 itself.
.SS void operator\-= (const \f[C]linear_regression_model<T>\f[]& model)
.PP
This operator is used to subtract two linear regression models.
But instead of returning a new model, it updates the target model with
the resultant model.
If m1 and m2 are two models, then "m1 \-= m2" will subtract m2 from m1
and update m1 itself.
.SS Pubic Member Function Documentation
.SS \f[C]std::vector<T>\f[] predict (DATA_MATRIX& mat)
.PP
This function is used on a trained model (after training is done by
respective trainers) to predict the unknown output labels based on the
given input matrix.
It uses prediction logic according to linear regression algorithm.
.PP
This function expects any input data matrix which provides an overloaded
multiply "*" operator with a vector type object.
E.g., if "v" is an object of \f[C]std::vector<T>\f[] type, then "mat *
v" should be supported and it should return the resultant vector of the
type \f[C]std::vector<T>\f[].
DATA_MATRIX can be \f[C]frovedis::crs_matrix_local<T>\f[],
\f[C]frovedis::ell_matrix_local<T>\f[] etc.
.PP
On succesful prediction, this function returns the predicted values in
the form of \f[C]std::vector<T>\f[].
It will throw an exception, if any error occurs.
.SS size_t get_num_features () const
.PP
It returns the number\-of\-features in the target model.
.SS void save (const std::string& path) const
.PP
It saves the target model in the specified path in simple text format.
It will throw an exception, if any error occurs during the save
operation.
.SS void savebinary (const std::string& path) const
.PP
It saves the target model in the specified path in (little\-endian)
binary data format.
It will throw an exception, if any error occurs during the save
operation.
.SS void load (const std::string& path) const
.PP
It loads the target linear regression model from the data in specified
text file.
It will throw an exception, if any error occurs during the load
operation.
.SS void loadbinary (const std::string& path) const
.PP
It loads the target linear regression model from the data in specified
(little\-endian) binary file.
It will throw an exception, if any error occurs during the load
operation.
.SS void debug_print() const
.PP
It prints the contents of the model on the user terminal.
It is mainly useful for debugging purpose.
.SS \f[C]node_local<linear_regression_model<T>>\f[] broadcast ()
.PP
It broadcasts the target model to all the participating MPI processes
(worker nodes) in the system.
This is an efficient (as it does not involve the serialization overhead
of the model weight vector) implementation than simple
"frovedis:broadcast(model)" call.
.SS Public Data Member Documentation
.SS weight
.PP
An object of \f[C]std::vector<T>\f[] type.
It is used to store the weight/theta components associated with each
training features.
.SS intercept
.PP
A "T" type object (mainly "float" or "double").
It is used to store the bias intercept term of the model.
.SH SEE ALSO
.PP
logistic_regression_model, svm_model
